// pages/ktk/detail/detail.js
function formatNumber(n) {
    n = n.toString();
    return n[1] ? n : '0' + n
}
try {
    var WxParse= require('../../../wxParse/wxParse.js');
}catch (e) {
    console.log(e);
}

Page({

  /**
   * 页面的初始数据
   */
  data: {
  detail_data:[],
  lable:[],
  is_hover:false
  },
    dianzan:function(){
        console.log(222)
        this.setData({
            is_hover:true
        })
    },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      var that = this;
      wx.request({
          url: 'https://www.ggd4.cn/wap/actLibrary/detail',
          data: {
              id: options.id
          },
          header: {
              'content-type': 'application/json;' // 默认值
          },
          success: function(res) {
              res.data.data.data.al_start_time = that.turntime(res.data.data.data.al_start_time,'Y/M/D');
              res.data.data.data.al_end_time = that.turntime(res.data.data.data.al_end_time,'Y/M/D');
             /* console.log(that.turntime(res.data.data.data.al_start_time,'Y/M/D'));*/
            /*  console.log(WxParse.wxParse('article','html',res.data.data.data.al_content,that,5));*/
              WxParse.wxParse('article','html',res.data.data.data.al_content,that,5);
              that.setData({
                  detail_data:res.data.data.data,
                  lable:res.data.data.label
              });
          }
      })
  },
   turntime:function(number,format){
      if(number == 0 ){
          return '请关注官方'
      }else{
          var formateArr  = ['Y','M','D','h','m','s'];
          var returnArr   = [];

          var date = new Date(number * 1000);
          returnArr.push(date.getFullYear());
          returnArr.push(formatNumber(date.getMonth() + 1));
          returnArr.push(formatNumber(date.getDate()));

          returnArr.push(formatNumber(date.getHours()));
          returnArr.push(formatNumber(date.getMinutes()));
          returnArr.push(formatNumber(date.getSeconds()));

          for (var i in returnArr)
          {
              format = format.replace(formateArr[i], returnArr[i]);
          }
          return format
      }

   },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})